package com.reach.redis.proxy;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
 
public class CGLIBProxy {
 
    public static Object createProxy(final Object targetObj, final MethodInterceptor cacheAspect) {
    	try {
	        Enhancer enhancer = new Enhancer();
	        // 设置需要代理的父类
	        enhancer.setSuperclass(targetObj.getClass());
	        // 设置回调
	        enhancer.setCallback(cacheAspect);
	        // 3.4 创建代理
	        return enhancer.create();
    	}catch(Exception e) {
    		e.printStackTrace();
    	}
    	return null;
    }
}